package com.xhs.controller;

import com.xhs.design.factory.FactoryHandler;
import com.xhs.message.ReturnResult;
import com.xhs.service.AbstractLevelHandler;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @desc: 责任链模式
 * @projectName: tools-parent
 * @author: xhs
 * @date: 2022/12/5 10:32
 * @version: JDK 1.8
 */
@RestController
@RequestMapping("/chain")
public class ChainController {

    /**
     * 闯关
     *
     * @return
     */
    @PostMapping("/levelChain")
    public ReturnResult<String> levelChain() {
        AbstractLevelHandler levelHandler = FactoryHandler.getLevelHandler();
        Boolean service = levelHandler.doService();
        if (service) {
            return ReturnResult.success("闯关成功");
        }
        return ReturnResult.error("闯关失败");
    }
}
